<?php
if (!defined('THINK_PATH')) exit();

class cacheModel{
	public function getCache($className,$funName,$cacheTime = 3600){
		$path = CACHE_PATH.$className.'/'.'~'.md5($funName).'.cache.php';
		$emtime = filemtime($path);
		if(time() - $emtime>$cacheTime) return false;
		if(C('HZY_CACHE') && is_file($path)){
			return include $path;
		}
		return false;
	}
	public function addCache($calssName,$funName,$con){
		$path = CACHE_PATH.$calssName.'/'.'~'.md5($funName).'.cache.php';
		if(!is_dir(dirname($path))) mk_dir(dirname($path),0777);
		if(is_array($con)){
			file_put_contents($path,'<?php return '.var_export($con, true).'?>');
			return true;
		}else{
			file_put_contents($path, $con);
			return true;
		}
		return false;
	}
	
}